package impl.javasistimpl;

import javassist.util.proxy.MethodHandler;

import java.lang.reflect.Method;

/**
 * Created by chenjun on 2017/11/22.
 */
public class JavaAssitInterceptor implements MethodHandler {
    final Object delegate;

   public JavaAssitInterceptor(Object delegate) {
        this.delegate = delegate;
    }

    @Override
    public Object invoke(Object self, Method m, Method proceed,
                         Object[] args) throws Throwable {
        before();
        Object result =  m.invoke(delegate, args);
        after();
        return  result;
    }

    public  void before(){
        System.out.println("---javassist before----");

    }

    public  void after(){
        System.out.println("---javassist after----");
    }
}
